package com.haoyi.feignapi.controller;

import com.haoyi.feignapi.entity.erp.ErpOCC;
import com.haoyi.feignapi.entity.ocm.*;
import com.haoyi.feignapi.service.OcmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Map;

@RestController
@RequestMapping("/ocm")
public class OcmController {

    private final OcmService ocmService;

    public OcmController(OcmService ocmService) {
        this.ocmService = ocmService;
    }


    @PostMapping("/getCag")
    public Map<String, Object> getCag(@RequestBody Map<String, Object> paramMap) {
        return ocmService.getCag(paramMap);
    }


    @PostMapping("/getDan")
    public Map<String, Object> getDan(@RequestBody Map<String, Object> paramMap) {
        return ocmService.getDan(paramMap);
    }

    @PostMapping("/insertOcmOrder")
    public Map<String, Object> insertOcmOrder(@RequestBody Map<String, Object> paramMap) {
        return ocmService.insertOcmOrder(paramMap);
    }


    @PostMapping("/checkErpCode")
    public Map<String, Object> checkErpCode(@RequestBody Map<String, Object> paramMap) {
        return ocmService.checkErpCode(paramMap);
    }

    @PostMapping("/insert")
    public int insert(@RequestBody ErpOCC erpOCC) {
        return ocmService.insertOCM(erpOCC);
    }

    @PostMapping("/allOCM")
    public ArrayList<HbaOCM> allOCM() {
        ArrayList<HbaOCM> hbaOCMS = ocmService.allOCM();
        return hbaOCMS;
    }

    @GetMapping("/del")
    public int del(){
        return ocmService.del();
    }

    @PostMapping("/insertHBA")
    public int insertHBA(@RequestBody HbaOCM habOCM){
        return ocmService.insert(habOCM);
    }
}
